package modul.pencatatan.dataoperator;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

public class operatorTabelModel extends AbstractTableModel {

    private List<Operator> isi = new ArrayList<Operator>();

    public void tambahOperator(Operator o) {
        isi.add(o);
        fireTableRowsInserted(getRowCount(), getColumnCount());
    }

    public void hapusTabel(int i, int row) {
        isi.remove(i);
        fireTableRowsDeleted(i, row);
    }

    public Operator getJenisFilm(int index) {
        return (Operator) isi.get(index);
    }

    @Override
    public int getRowCount() {
        return isi.size();
    }

    @Override
    public int getColumnCount() {
        return 8;
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "ID";
            case 1:
                return "Nama Operator";
            case 2:
                return "Alamat";
            case 3:
                return "Kota";
            case 4:
                return "Provinsi";
            case 5:
                return "Telepon";
            case 6:
                return "Note";
            case 7:
                return "Password";
            default:
                return null;
        }
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return isi.get(rowIndex).getID_Operator();
            case 1:
                return isi.get(rowIndex).getNama_Operator();
            case 2:
                return isi.get(rowIndex).getAlamat();
            case 3:
                return isi.get(rowIndex).getKota();
            case 4:
                return isi.get(rowIndex).getPropinsi();
            case 5:
                return isi.get(rowIndex).getTelepon();
            case 6:
                return isi.get(rowIndex).getNote();
            case 7:
                return isi.get(rowIndex).getPassword();
            default:
                return null;
        }
    }
}
